
// <copyright file="MessageAndObjectPairEqualityComparer.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The message and object pair equality comparer.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Messaging
{
    using System.Collections.Generic;
    using System.Messaging;

    /// <summary>
    /// The message and object pair equality comparer.
    /// </summary>
    /// <typeparam name="T">
    /// </typeparam>
    public sealed class MessageAndObjectPairEqualityComparer<T> : IEqualityComparer<KeyValuePair<Message, T>>
    {
        #region Public Methods and Operators

        /// <summary>
        /// The equals.
        /// </summary>
        /// <param name="x">
        /// The x.
        /// </param>
        /// <param name="y">
        /// The y.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Equals(KeyValuePair<Message, T> x, KeyValuePair<Message, T> y)
        {
            return x.Value.Equals(y.Value);
        }

        /// <summary>
        /// The get hash code.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int GetHashCode(KeyValuePair<Message, T> obj)
        {
            return ~obj.Value.GetHashCode();
        }

        #endregion Public Methods and Operators
    }
}
